package com.itheima.myscoket.test6;

import java.io.*;
import java.net.Socket;

public class ClientDemo {
    public static void main(String[] args) throws IOException {
        //先将文件传入创造的网络流中(传输中的流)
        Socket socket = new Socket("127.0.0.1",10000);
        //把文件放入
        OutputStream os = socket.getOutputStream();
        os.write("hello".getBytes());
        //关闭流
        socket.shutdownOutput();
        //接收服务器传过来的信息
//        InputStream is = socket.getInputStream();
//        int len;
//        while((len = is.read())!=-1){
//            System.out.println(len);
//        }

        //用字符流进行接收 BufferedReader br = new BufferedReader(new FileReader());
        BufferedReader br = new BufferedReader(new InputStreamReader(socket.getInputStream()));
        String line;
        while((line = br.readLine())!=null){
            System.out.println(line);
        }
        br.close();
        socket.close();
        os.close();

    }
}
